package com.tengju.user.domain.model.archive.letax;

import com.fasterxml.jackson.annotation.JsonValue;

public enum LetaxStatus {

    UN_APPLY(0, "待申请"),
    FINISHED(1, "注册完成"),
    RELATE_FAILED(2, "关联失败"),
    TERMINATED(3, "终止"),
    APPLIED(4, "申请中"),
    REGISTERED(5, "注册中"),
    REGISTER_FAILED(6, "注册失败"),
    NEED_AUTH(7, "需要重新授权"),
    ;

    private int val;
    private String desc;

    LetaxStatus(int val, String desc) {
        this.val = val;
        this.desc = desc;
    }

    @JsonValue
    public int getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public static LetaxStatus form(int val) {
        LetaxStatus result = null;
        for (LetaxStatus status : LetaxStatus.values()) {
            if (status.getVal() == val) {
                result = status;
            }
        }
        return result;
    }

    //是否为乐税处理中状态
    public static boolean inHand (LetaxStatus letaxStatus) {

        return LetaxStatus.UN_APPLY == letaxStatus
                || LetaxStatus.APPLIED == letaxStatus
                || LetaxStatus.REGISTERED == letaxStatus
                || LetaxStatus.NEED_AUTH ==letaxStatus;

    }

}
